﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ContadorDeHoras.DTO;
using System.Data.SqlClient;

namespace ContadorDeHoras.DAL
{
    public class CommandPersiste:ICommand
    {
        private DiaDTO dia;

        public CommandPersiste(DiaDTO dia) {
            this.dia = dia;
        }

        public object execute()
        {
            bool retorno = false;
            Connection conexao = Connection.getConnection();
            SqlCommand c = new SqlCommand("i_sp_tb_dia", conexao.getConexao());
            c.CommandType = System.Data.CommandType.StoredProcedure;
            c.Parameters.Add(new SqlParameter("@in_idt_dia", string.Format("{0:yyyy-MM-dd}", this.dia.Dia)));
            c.Parameters.Add(new SqlParameter("@in_des_manha_inicio", this.dia.ManhaInicio));
            c.Parameters.Add(new SqlParameter("@in_des_manha_fim", this.dia.ManhaFim));
            c.Parameters.Add(new SqlParameter("@in_des_tarde_inicio", this.dia.TardeInicio));
            c.Parameters.Add(new SqlParameter("@in_des_tarde_fim", this.dia.TardeFim));
            c.ExecuteNonQuery();
            conexao.closeConexao();
            return retorno;
        }
    }
}
